//
// * Copyright (c) 2002-2009 "Neo Technology,"
// *     Network Engine for Objects in Lund AB [http://neotechnology.com]
// *
// * This file is part of Neo4j.
// * 
// * Neo4j is free software: you can redistribute it and/or modify
// * it under the terms of the GNU Affero General Public License as
// * published by the Free Software Foundation, either version 3 of the
// * License, or (at your option) any later version.
// * 
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// * GNU Affero General Public License for more details.
// * 
// * You should have received a copy of the GNU Affero General Public License
// * along with this program. If not, see <http://www.gnu.org/licenses/>.
// 
#region Using Directives

using Node = org.neo4j.graphdb.Node;
using Relationship = org.neo4j.graphdb.Relationship;
using TraversalPosition = org.neo4j.graphdb.TraversalPosition;

#endregion
namespace org.neo4j.kernel.impl.traversal
{
    /// <summary>
    /// 
    /// </summary>
	public class TraversalPositionImpl : TraversalPosition
	{
        #region Private Variables

        /// <summary>
        /// 
        /// </summary>
        private Node currentNode = null;
        /// <summary>
        /// 
        /// </summary>
        private Node previousNode = null;
        /// <summary>
        /// 
        /// </summary>
        private Relationship lastRelTraversed = null;
        /// <summary>
        /// 
        /// </summary>
        private int currentDepth = -1;
        /// <summary>
        /// 
        /// </summary>
        private int returnedNodesCount = -1;

        #endregion

        #region Implementations

        #region Internal Implementations

        /// <summary>
        /// 
        /// </summary>
        /// <param name="currentNode"></param>
        /// <param name="previousNode"></param>
        /// <param name="lastRelTraversed"></param>
        /// <param name="currentDepth"></param>
        internal TraversalPositionImpl(Node currentNode, Node previousNode, Relationship lastRelTraversed, int currentDepth)
        {
            this.currentNode = currentNode;
            this.previousNode = previousNode;
            this.lastRelTraversed = lastRelTraversed;
            this.currentDepth = currentDepth;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="returnedNodesCount"></param>
        internal virtual void SetReturnedNodesCount(int returnedNodesCount)
        {
            this.returnedNodesCount = returnedNodesCount;
        }

        #endregion

        #region Public Implementations


        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public virtual Node CurrentNode()
        {
            return this.currentNode;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public virtual Node PreviousNode()
        {
            return this.previousNode;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public virtual Relationship LastRelationshipTraversed()
        {
            return this.lastRelTraversed;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public virtual int Depth()
        {
            return this.currentDepth;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public virtual int ReturnedNodesCount()
        {
            return this.returnedNodesCount;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public virtual bool NotStartNode()
        {
            return this.Depth() > 0;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public virtual bool IsStartNode()
        {
            return this.Depth() == 0;
        }

        #endregion

        #endregion
	}
}